package com.polaris.live.popup

import android.content.Context
import com.blankj.utilcode.util.StringUtils
import com.lxj.xpopup.core.CenterPopupView
import com.polaris.live.R
import com.polaris.live.common.ext.setOnSingleClickListener
import com.polaris.live.databinding.PopupInsufficientBalanceBinding
import com.polaris.live.translation.R.string

/**
 *  余额不足
 * @author Created by 天晴 on 2024/3/21 19:18
 * @since 1.0.0
 **/
class InsufficientBalancePopup(
    context: Context,
    private val type: Int,
    private val onRecharge: () -> Unit, //充值
    private val onExchange: () -> Unit, //兑换
) : CenterPopupView(context) {
    private lateinit var mBinding: PopupInsufficientBalanceBinding
    override fun getImplLayoutId(): Int {
        return R.layout.popup_insufficient_balance
    }


    override fun onCreate() {
        super.onCreate()
        mBinding = PopupInsufficientBalanceBinding.bind(popupImplView)
        if(type == 0) {
            mBinding.message.text = StringUtils.getString(string.unfortunately_zs)
            mBinding.ok.text = StringUtils.getString(string.go_recharge)
        }else {
            mBinding.message.text = StringUtils.getString(string.unfortunately_yxb)
            mBinding.ok.text = StringUtils.getString(string.go_exchange)
        }
        mBinding.ok.setOnSingleClickListener {
            dismiss()
            if (type == 0) {
                onRecharge.invoke()
            } else {
                onExchange.invoke()
            }
        }
        mBinding.cancel.setOnSingleClickListener {
            dismiss()
        }
    }
}